#ifndef WLISTSOURCEMODEL_H
#define WLISTSOURCEMODEL_H

#include <QAbstractItemModel>
#include <QFileInfo>
#include <QFutureWatcher>
class WListPatient;

class WListSourceModel : public QAbstractItemModel
{
    Q_OBJECT
public:
    explicit WListSourceModel(QObject *parent = 0);
    ~WListSourceModel();

    int rowCount(const QModelIndex &parent) const;
    int columnCount(const QModelIndex &parent) const;
    //bool insertRows(int row, int count, const QModelIndex &parent);
    bool removeRows(int row, int count, const QModelIndex &parent);
    QModelIndex parent(const QModelIndex &child) const;
    QVariant data(const QModelIndex &index, int role) const;
    bool setData(const QModelIndex &index, const QVariant &value, int role);
    QModelIndex index(int row, int column, const QModelIndex &parent) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role) const;

    int insertPatient(WListPatient *patient, int row = 0, const QModelIndex &parent = QModelIndex());
    void setupModel();

signals:
    void setupFinished();

protected slots:
    void onResultReadyAt(int index);
    void onWatcherFinished() { emit setupFinished(); }

private:
    QFutureWatcher<WListPatient*> watcher;
    int saveFileFormatToDB(WListPatient &patient);
    QList<WListPatient*> patientList;

};

#endif // WLISTSOURCEMODEL_H
